package cn.iocoder.yudao.module.blog.dal.mysql.postcomment;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.blog.controller.app.post.commentvo.AppBlogPostCommentPageReqVO;
import cn.iocoder.yudao.module.blog.controller.app.space.commentvo.AppBlogSpaceCommentPageReqVO;
import cn.iocoder.yudao.module.blog.dal.dataobject.postcomment.BlogPostCommentDO;
import cn.iocoder.yudao.module.blog.dal.dataobject.spacecomment.BlogSpaceCommentDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.blog.controller.admin.postcomment.vo.*;

/**
 * 帖子评论 Mapper
 *
 * @author 曹建伟
 */
@Mapper
public interface BlogPostCommentMapper extends BaseMapperX<BlogPostCommentDO> {

    default PageResult<BlogPostCommentDO> selectPage(BlogPostCommentPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<BlogPostCommentDO>()
                .eqIfPresent(BlogPostCommentDO::getMemberId, reqVO.getMemberId())
                .eqIfPresent(BlogPostCommentDO::getPostId, reqVO.getPostId())
                .betweenIfPresent(BlogPostCommentDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(BlogPostCommentDO::getId));
    }

    default List<BlogPostCommentDO> selectList(BlogPostCommentExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<BlogPostCommentDO>()
                .eqIfPresent(BlogPostCommentDO::getMemberId, reqVO.getMemberId())
                .eqIfPresent(BlogPostCommentDO::getPostId, reqVO.getPostId())
                .betweenIfPresent(BlogPostCommentDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(BlogPostCommentDO::getId));
    }

    default PageResult<BlogPostCommentDO> appSelectPage(AppBlogPostCommentPageReqVO reqVO){
        return selectPage(reqVO, new LambdaQueryWrapperX<BlogPostCommentDO>()
                .eqIfPresent(BlogPostCommentDO::getMemberId, reqVO.getMemberId())
                .eqIfPresent(BlogPostCommentDO::getPostId, reqVO.getPostId())
                .eqIfPresent(BlogPostCommentDO::getMainCommentId, reqVO.getMainCommentId())
                .orderByDesc(BlogPostCommentDO::getId));
    }

}
